package com.itlong.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;

/**
 * <desc>
 *      旺龙服务网关
 * </desc>
 *
 * @createDate 2018/8/23
 */
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableZuulProxy
public class GetwayServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(GetwayServerApplication.class, args);

        //设置tomcat入参允许输入字符
        System.setProperty("tomcat.util.http.parser.HttpParser.requestTargetAllow","|{}");
    }
//
//    /**
//     * <desc>
//     *
//     * </desc>
//     * @return
//     */
//    @Bean
//    public EmbeddedServletContainerFactory servletContainerFactory() {
//        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
//            @Override
//            protected void postProcessContext(Context context) {
//                SecurityConstraint securityConstraint = new SecurityConstraint();
//                securityConstraint.setUserConstraint("CONFIDENTIAL");
//                SecurityCollection collection = new SecurityCollection();
//                collection.addMethod("post");
//                collection.addPattern("/*");
//                securityConstraint.addCollection(collection);
//                context.addConstraint(securityConstraint);
//            }
//        };
//        tomcat.addAdditionalTomcatConnectors(httpConnector());
//        return tomcat;
//    }
//
//   /**
//     * <desc>
//     *      初始化tomcat connector 设置http强制跳转https
//     * </desc>
//     *
//     * @return
//     * @author Jiaqi.X
//     * @createDate 2018/07/09
//     */
//    @Bean
//    public Connector httpConnector(){
//        Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
//        connector.setScheme("http");
//        connector.setPort(8999);
//        connector.setSecure(false);
//        connector.setAttribute("maxHttpHeaderSize","4048576");
////        connector.setRedirectPort(443);
//        return connector;
//    }

}
